package o;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.huawei.hmf.annotation.ApiDefine;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import o.cxu.b;
import o.cxv.a;
import o.cyf.d;

@ApiDefine(uri = cxu.class)
public class cyb implements cxu {
    private String ʻ;
    private b ʼ;
    private String ʽ;
    private boolean ˊ = false;
    private cxv<cxs> ˋ;
    private fhz ˎ;
    private int ˏ;
    private Context ˏॱ;
    private cxs ͺ;
    private cyf ॱ;
    private boolean ॱˊ;
    private String ॱॱ;
    private String ᐝ;

    Integer ˎ(Object... objArr) {
        if (!this.ͺ.ˋ()) {
            return Integer.valueOf(1);
        }
        if (!ॱ()) {
            return Integer.valueOf(2);
        }
        if (!this.ॱ.ˊ(this.ˏॱ)) {
            return Integer.valueOf(3);
        }
        if (this.ॱ.ˋ(this.ˏॱ, this.ͺ.ˊ())) {
            return Integer.valueOf(5);
        }
        if (ˊ(this.ˏॱ, this.ͺ)) {
            return Integer.valueOf(4);
        }
        return Integer.valueOf(0);
    }

    boolean ॱ() {
        fhq ˏ = fho.ˏ();
        if (ˏ == null) {
            return false;
        }
        this.ˎ = ˏ.ˋ("ShortcutManager");
        if (this.ˎ == null) {
            return false;
        }
        this.ॱ = (cyf) this.ˎ.ॱ(cyf.class);
        if (this.ॱ == null) {
            return false;
        }
        return true;
    }

    boolean ˊ(Context context, cxs o_cxs) {
        boolean z;
        List<cxx> arrayList = new ArrayList();
        this.ॱ.ˊ(context, (List) arrayList);
        for (cxx o_cxx : arrayList) {
            if (!cyh.ˋ(o_cxx.ॱ()).equals(o_cxs.ˊ())) {
                if (this.ˋ != null && this.ˋ.ˎ(o_cxs, o_cxx)) {
                    z = true;
                    break;
                }
            } else {
                z = true;
                break;
            }
        }
        z = false;
        cyk.ˏ.ˋ("ShortcutBundle", "The shortcut is exist: " + z);
        return z;
    }

    static String ॱ(int i) {
        switch (i) {
            case 0:
                return "Interaction mode.";
            case 1:
                return "Invalid shortcut data.";
            case 2:
                return "Failed to query the 'ShortcutManager' interface.";
            case 3:
                return "Creating shortcuts is not supported.";
            case 4:
                return "The shortcut already exists.";
            case 5:
                return "The reminder has been marked as no longer displayed.";
            default:
                return "Unknown " + String.valueOf(i) + ".";
        }
    }

    void ˋ(Integer num) {
        cyk.ˏ.ˋ("ShortcutBundle", "Status code: " + this.ˏ + " - " + ॱ(this.ˏ));
        this.ˏ = num.intValue();
        if (this.ˏ == 0 && !this.ॱˊ) {
            ʽ();
        } else if (this.ˋ != null) {
            this.ˋ.ˎ(this.ͺ, this.ˏ);
        }
    }

    DialogFragment ˊ() {
        String ᐝ = ᐝ();
        fjb ˎ = this.ˎ.ˎ("ShortcutConfirm");
        cyd o_cyd = (cyd) ˎ.ˊ();
        o_cyd.ˏ(this.ͺ.ˊ());
        o_cyd.ॱ(ᐝ);
        o_cyd.ॱ(this.ˊ);
        o_cyd.ˎ(this.ᐝ);
        o_cyd.ˊ(this.ʻ);
        o_cyd.ʻ(this.ॱॱ);
        o_cyd.ˋ(this.ʽ);
        fiw ˋ = fiu.ˊ().ˋ(this.ˏॱ, ˎ);
        cye o_cye = (cye) ˋ.ˎ(cye.class);
        if (o_cye != null) {
            o_cye.ˋ(new cyg(this) {
                final /* synthetic */ cyb ˊ;

                {
                    this.ˊ = r1;
                }

                public void ˏ() {
                    this.ˊ.ˎ();
                    this.ˊ.ˏ();
                }

                public void ˊ() {
                    this.ˊ.ˋ();
                }

                public void ˋ() {
                    this.ˊ.ʼ();
                }

                public void ˎ() {
                    this.ˊ.ॱॱ();
                }
            });
        }
        return (DialogFragment) ˋ.ˊ();
    }

    void ˎ() {
        if (this.ˋ != null) {
            this.ˋ.ॱ(this.ͺ, new a(this) {
                final /* synthetic */ cyb ˊ;

                {
                    this.ˊ = r1;
                }

                public void ॱ(final cxx o_cxx) {
                    if (o_cxx != null) {
                        new Handler(Looper.getMainLooper()).post(new Runnable(this) {
                            final /* synthetic */ AnonymousClass1 ˊ;

                            public void run() {
                                this.ˊ.ˊ.ˎ(this.ˊ.ˊ.ˏॱ, o_cxx);
                            }
                        });
                    }
                }
            });
        }
    }

    void ˎ(Context context, cxx o_cxx) {
        cyk.ˏ.ˋ("ShortcutBundle", "Request to pin shortcut.");
        this.ॱ.ˏ(context, o_cxx, new d(this) {
            final /* synthetic */ cyb ˏ;

            {
                this.ˏ = r1;
            }

            public void ˊ(cxx o_cxx) {
                cyk.ˏ.ˋ("ShortcutBundle", "Request to pin shortcut: pinned.");
                if (this.ˏ.ˋ != null) {
                    this.ˏ.ˋ.ˋ(this.ˏ.ͺ);
                }
            }
        });
    }

    private String ᐝ() {
        if (TextUtils.isEmpty(this.ͺ.ˏ())) {
            return this.ͺ.ॱ();
        }
        return this.ͺ.ˏ();
    }

    void ˏ() {
        if (this.ʼ != null) {
            this.ʼ.ˊ();
        }
    }

    void ˋ() {
        if (this.ʼ != null) {
            this.ʼ.ˎ();
        }
    }

    void ॱॱ() {
        if (this.ʼ != null) {
            this.ʼ.ॱ();
        }
    }

    void ʼ() {
        if (this.ʼ != null) {
            this.ʼ.ˏ();
        }
    }

    public <Data extends cxs> void ˋ(cxv<Data> o_cxv_Data) {
        this.ˋ = o_cxv_Data;
    }

    public void ˏ(boolean z) {
        this.ˊ = z;
    }

    public void ˊ(String str) {
        this.ʽ = str;
    }

    public void ˏ(String str) {
        this.ॱॱ = str;
    }

    public void ˏ(b bVar) {
        this.ʼ = bVar;
    }

    public <Data extends cxs> void ˎ(Context context, Data data, Executor executor, boolean z) {
        if (context == null || !(context instanceof Activity)) {
            throw new IllegalArgumentException("context must not be null, and context must be instance of Activity.");
        } else if (data == null) {
            throw new IllegalArgumentException("shortcutData must not be null.");
        } else {
            this.ॱˊ = z;
            this.ˏॱ = context;
            this.ͺ = data;
            ॱ(executor);
        }
    }

    void ॱ(Executor executor) {
        AsyncTask anonymousClass3 = new AsyncTask<Object, Object, Integer>(this) {
            final /* synthetic */ cyb ˏ;

            {
                this.ˏ = r1;
            }

            protected /* synthetic */ Object doInBackground(Object[] objArr) {
                return ˊ(objArr);
            }

            protected /* synthetic */ void onPostExecute(Object obj) {
                ˏ((Integer) obj);
            }

            protected Integer ˊ(Object... objArr) {
                return this.ˏ.ˎ(objArr);
            }

            protected void ˏ(Integer num) {
                this.ˏ.ˋ(num);
            }
        };
        if (executor != null) {
            anonymousClass3.executeOnExecutor(executor, new Object[0]);
        } else {
            anonymousClass3.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
        }
    }

    void ʽ() {
        ˊ((Activity) this.ˏॱ, ˊ());
    }

    static boolean ˊ(Activity activity, DialogFragment dialogFragment) {
        if (ˊ(activity)) {
            cyk.ˏ.ˊ("ShortcutBundle", "Fail to show the confirm-dialog, because the activity is destroyed.");
            return false;
        }
        String name = dialogFragment.getClass().getName();
        FragmentTransaction beginTransaction = activity.getFragmentManager().beginTransaction();
        Fragment findFragmentByTag = activity.getFragmentManager().findFragmentByTag(name);
        if (findFragmentByTag != null) {
            beginTransaction.remove(findFragmentByTag);
        }
        beginTransaction.addToBackStack(null);
        try {
            dialogFragment.show(beginTransaction, name);
            return true;
        } catch (Exception e) {
            cyk.ˏ.ˊ("ShortcutBundle", "Fail to show the confirm-dialog, exception: " + e);
            return false;
        }
    }

    @TargetApi(17)
    static boolean ˊ(Activity activity) {
        if (activity.isFinishing() || (VERSION.SDK_INT >= 17 && activity.isDestroyed())) {
            return true;
        }
        return false;
    }
}
